'''
继承

'''
class Pets:# 父类或者基类
    def __init__(self,nickname,age):
        self.nickname = nickname
        self.age = age
        self.color = '黑色'

    def eat(self):
        print('正在吃')

    def play(self):
        print('正在玩')

    def sleep(self):
        print('正在睡觉')

class Dog(Pets): #子类或者派生类
    #狗的类是从Pets的类继承而来的
   def __init__(self,nickname,age):
        super().__init__(nickname,age)

        self.color = '黄色'


class Cat(Pets):
    def eat(self,food):
        print(f'{self.nickname}爱吃{food}')
        # Pets.eat(self)
        super(Cat,self).eat()
d = Dog('金毛',2)
print (d.nickname)
print(d.age)
print (d.color)

c = Cat('加菲',3)
print (c.nickname)
print(c.age)
c.eat('鱼')
c.play()
c.sleep()
